<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>demo</title>
    <script src="../plugins/vue/vue.js"></script>
    <script src="../plugins/elementui/index.js"></script>
    <script src="../plugins/vue/axios-0.18.0.js"></script>
    <script src="../plugins/healthmobile.js"></script>
    <script src="../js/qrcode.js"></script>
</head>
<body>
<div id="qrCode"></div>


<script>

    let id =  getUrlParam("id");

    let vue = new Vue({
        data:{
            payOrder:""
        },
        created(){
            axios.get("/pay/wxpay/"+id).then(res=>{
                new QRCode('qrCode',{
                    text:res.data.data,
                    width:200,
                    height:200,
                    // colorLight: '#e21918',
                    // colorDark: '#0078d7',
                    correctLevel: QRCode.CorrectLevel.M
                })
                // this.payOrder=res.data.data;
            })
        }
    });


    // 每间隔五秒查询支付状态
    setInterval(function () {
        // 发送ajax请求
        axios.get("/pay/check/"+id).then(res=>{
            if(res.data.data){
                // 支付成功了
                location.href='pay_success.html';
            }
        })},5000);

    // 如果用户迟迟没有支付... 帅哥课上演示20秒
    setTimeout(function () {
        location.href='pay_fail.html';
    },20000);




</script>

</body>
</html>